package ais.dcproject.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import ais.dcproject.service.DropListService;

public class DropListAction {
	private DropListService dropListService;

	private Integer departmentId;

	private List specialsJSON;

	public void setDropListService(DropListService dropListService) {
		this.dropListService = dropListService;
	}

	public Integer getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Integer departmentId) {
		this.departmentId = departmentId;
	}

	public List getSpecialsJSON() {
		return specialsJSON;
	}

	public String getSpecials() throws IOException {
		String responseText = dropListService.getAllSpecialsByDepartmentId(getDepartmentId());
		HttpServletResponse response = ServletActionContext.getResponse();
		try {
			response.setContentType("text/html;charset=UTF-8");
			response.getWriter().print(responseText);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
